#include <iostream>
#include <string>
#include <fstream>
#include <limits>
using std::cout;
using std::endl;
using std::cin;
using std::cerr;
using std::string;
using std::ifstream;

void readInt(int & number){
    cout << "请输入一个整型" << endl;
    cin >> number;
    while(!cin.eof()){
        if(cin.bad()){
            cerr << "cin is bad" << endl;
            return;
        }else if(cin.fail()){
            cin.clear();
            cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
            cout << "重新输入：" << endl;
            cin >> number;
        }else{
            cout << "num:" << number << endl;
            break;
        }

    }
}

void test0(){
    int num = 0 ;
    readInt(num);
}

int main(int argc, char * argv[])
{
    test0();
    return 0;
}


